package com.ruoyi.club.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.club.domain.CmsClubClslevel;
import com.ruoyi.club.service.ICmsClubClslevelService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 俱乐部课程级别Controller
 * 
 * @author miki
 * @date 2024-10-01
 */
@Controller
@RequestMapping("/club/clslevel")
public class CmsClubClslevelController extends BaseController
{
    private String prefix = "club/clslevel";

    @Autowired
    private ICmsClubClslevelService cmsClubClslevelService;

    @RequiresPermissions("club:clslevel:view")
    @GetMapping()
    public String clslevel()
    {
        return prefix + "/clslevel";
    }

    /**
     * 查询俱乐部课程级别列表
     */
    @RequiresPermissions("club:clslevel:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CmsClubClslevel cmsClubClslevel)
    {
        startPage();
        List<CmsClubClslevel> list = cmsClubClslevelService.selectCmsClubClslevelList(cmsClubClslevel);
        return getDataTable(list);
    }

    /**
     * 导出俱乐部课程级别列表
     */
    @RequiresPermissions("club:clslevel:export")
    @Log(title = "俱乐部课程级别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CmsClubClslevel cmsClubClslevel)
    {
        List<CmsClubClslevel> list = cmsClubClslevelService.selectCmsClubClslevelList(cmsClubClslevel);
        ExcelUtil<CmsClubClslevel> util = new ExcelUtil<CmsClubClslevel>(CmsClubClslevel.class);
        return util.exportExcel(list, "俱乐部课程级别数据");
    }

    /**
     * 新增俱乐部课程级别
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存俱乐部课程级别
     */
    @RequiresPermissions("club:clslevel:add")
    @Log(title = "俱乐部课程级别", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CmsClubClslevel cmsClubClslevel)
    {
        return toAjax(cmsClubClslevelService.insertCmsClubClslevel(cmsClubClslevel));
    }

    /**
     * 修改俱乐部课程级别
     */
    @GetMapping("/edit/{clslevelId}")
    public String edit(@PathVariable("clslevelId") Long clslevelId, ModelMap mmap)
    {
        CmsClubClslevel cmsClubClslevel = cmsClubClslevelService.selectCmsClubClslevelById(clslevelId);
        mmap.put("cmsClubClslevel", cmsClubClslevel);
        return prefix + "/edit";
    }

    /**
     * 修改保存俱乐部课程级别
     */
    @RequiresPermissions("club:clslevel:edit")
    @Log(title = "俱乐部课程级别", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CmsClubClslevel cmsClubClslevel)
    {
        return toAjax(cmsClubClslevelService.updateCmsClubClslevel(cmsClubClslevel));
    }

    /**
     * 删除俱乐部课程级别
     */
    @RequiresPermissions("club:clslevel:remove")
    @Log(title = "俱乐部课程级别", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(cmsClubClslevelService.deleteCmsClubClslevelByIds(ids));
    }
}
